<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <span>身份证号：</span><input type="text" v-model.lazy='msg'><br>
        <span>年龄是：</span>
        <span>{{age}}</span>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        const ve = new Vue({
            el:'#app',
            data:{
                msg:'',
                age:0,
            },
            watch:{
                msg(val) {
                     let year = parseInt(val.slice(6,10))
                     const date = new Date()
                     const fullyear = date.getFullYear()
                     this.age = fullyear - year
                }
            }
        })
    </script>
</body>
</html>